package be.quadreg.dojo.model.entity;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import be.quadreg.dojo.persistence.GenericDAO;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Subclass;

@Subclass
public class SubscriptionHistoryMemberAttribute extends MemberAttribute {

	private Set<Key<MemberSubscription>> subscriptionHistoryKeys;

	
	public SubscriptionHistoryMemberAttribute() {
		subscriptionHistoryKeys = new HashSet<Key<MemberSubscription>>();
	}

	public Collection<MemberSubscription> getSubscriptionHistory() {
		return GenericDAO.getInstance().getSubscriptionHistory( subscriptionHistoryKeys );
	}

	public void addSubscription( MemberSubscription subscription ){
		Key<MemberSubscription> key = GenericDAO.getInstance().persistMemberSubscription(subscription);
		subscriptionHistoryKeys.add(key);
	}

	@Override
	public String toString() {
		return "SubscriptionHistoryMemberAttribute [subscriptionHistory="
				+ getSubscriptionHistory() + "]";
	}

	
}
